$(function () {
    $('body').on('click', "#theHostLive", function () {
        openInputName(1);
    }).on('click', "#theTeacherLive", function () {
        openInputName(2);
    }).on('click', "#theTaLive", function () {
        openInputName(3);
    });
});

function openInputName(type) {
    var liveId = $("#liveId").val();
    var roomid= $("#playurl").val();
    var teacherCode = $("#teachercode").val();
    var token= $("#admincode").val();
    var ptcode= $("#ptcode").val();
    var _ele = $('#openInputName').val()
    parent.layer.open({
        type: 1,
        area: ['240px', '180px'],
        skin: 'layui-layer-demo',
        title: '<strong>请输入姓名</strong>',
        content: _ele,
        btn: '确定',
        yes: function (index, layero) {
            var pass = layero.find('#rejectedCause').val();
            if (pass.length <= 0) {
                icModale(0, '请填写姓名');
                return;
            }
            if (pass.length >= 30) {
                icModale(0, '姓名不能大于30个字符');
                return;
            }
            icModale(0, '进入中');
            if (type == 1) {
                var url = "https://view.csslcloud.net/api/view/index?roomid=" + roomid + "&userid=" + liveId + "&autoLogin=true&viewername=" + pass + "&autoLogin=true&viewertoken=" + ptcode;
                window.open(url, "_blank");
            }
            if (type == 2) {
                window.location.href = "cclive://" + liveId + "/" + roomid + "/" + pass + "/" + teacherCode;
            }
            if (type == 3) {
                var url = "https://view.csslcloud.net/api/view/assistant?viewername=" + pass + "&roomid=" + roomid + "&userid=" + liveId + "&autoLogin=true&viewertoken=" + token;
                window.open(url, "_blank")
            }
            icModale(0, '进入中');
            parent.layer.closeAll();

        }
    });
}